package com.stu.dcxy.juc;

import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;

/**
 * @Author: MI
 * @Date: 2022/3/10/22:37
 * @Description: https://cdn.jsdelivr.net/gh/qianlicao51/files@main/img/2022-03/20220310225359.png
 * https://cdn.jsdelivr.net/gh/qianlicao51/files@main/img/2022-03/20220313210051.png
 */
public class LongAdderAPIDemo {
    public static void main(String[] args) {
        LongAdder longAdder = new LongAdder();

        longAdder.increment();
        longAdder.increment();
        longAdder.increment();

        System.out.println(longAdder.longValue());
        LongAccumulator
                longAccumulator = new LongAccumulator((x, y) -> x + y, 0);
        longAccumulator.accumulate(1);
        longAccumulator.accumulate(2);
        longAccumulator.accumulate(3);
        System.out.println(longAccumulator.longValue());
    }
}
